package com.xscha.tableforge.jooq.tables;

import org.jooq.*;
import org.jooq.Record;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import java.time.LocalDateTime;

/**
 * 关系映射表
 * 用于存储表之间的关系映射信息
 */
public class RelationMappingTable extends TableImpl<Record> {

    private static final long serialVersionUID = -1L;

    public static final RelationMappingTable RELATION_MAPPING = new RelationMappingTable();

    /** 映射ID */
    public final TableField<Record, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 关系字段ID */
    public final TableField<Record, String> RELATION_FIELD_ID = createField(DSL.name("relation_field_id"), SQLDataType.VARCHAR(36).nullable(false), this);
    /** 源记录ID */
    public final TableField<Record, String> SOURCE_RECORD_ID = createField(DSL.name("source_record_id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 目标记录ID */
    public final TableField<Record, String> TARGET_RECORD_ID = createField(DSL.name("target_record_id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 创建时间 */
    public final TableField<Record, LocalDateTime> CREATED_TIME = createField(DSL.name("created_time"), SQLDataType.LOCALDATETIME(3).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this);
    /** 最后修改时间 */
    public final TableField<Record, LocalDateTime> LAST_MODIFIED_TIME = createField(DSL.name("last_modified_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 删除时间 */
    public final TableField<Record, LocalDateTime> DELETED_TIME = createField(DSL.name("deleted_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 创建人 */
    public final TableField<Record, String> CREATED_BY = createField(DSL.name("created_by"), SQLDataType.VARCHAR.nullable(false), this);
    /** 最后修改人 */
    public final TableField<Record, String> LAST_MODIFIED_BY = createField(DSL.name("last_modified_by"), SQLDataType.VARCHAR, this);

    private RelationMappingTable() {
        super(DSL.name("relation_mapping"));
    }

    @Override
    public Schema getSchema() {
        return DSL.schema(DSL.name("public"));
    }

    @Override
    public UniqueKey<Record> getPrimaryKey() {
        return Keys.RELATION_MAPPING_PKEY;
    }

    @Override
    public RelationMappingTable as(String alias) {
        return new RelationMappingTable().as(alias);
    }

    @Override
    public RelationMappingTable as(Name alias) {
        return new RelationMappingTable().as(alias);
    }
} 